﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBMigrator.Core.DbObjects.Data.Select;
using Rhino.Mocks;
using StructureMap;
using Xunit;

namespace DBMigrator.Core.Tests.DbObjects.Data
{
    public class FromTests
    {
        private readonly IFromTable fromTable;

        public FromTests()
        {
            fromTable = MockRepository.GenerateMock<IFromTable>();
            ObjectFactory.Inject(fromTable);
        }

        [Fact]
        public void FromTableShouldBeNullByDefault()
        {
            Assert.Null(new From().FromTable);
        }

        [Fact]
        public void TableShouldSetFromTable()
        {
            var from = new From();
            Assert.Null(from.FromTable);
            from.Table("TableName");
            Assert.NotNull(from.FromTable);
        }

        [Fact]
        public void TableShouldReturnFromTable()
        {
            var from = new From();
            var result = from.Table("TableName");
            Assert.Equal(from.FromTable, result);
        }
    }
}
